 <#include "../common/head.ftl">
<div class="content">
    <div class="con_left1">
        <ul>
            <li>
   <#if enterpriseInit[0].ent_status=="0">
   <a href="javascript:void(0)" onclick="correctEmergent()">急招</a>
   <#else>
   <a href="javascript:void(0)" onclick="erroremergentMsg();">急招</a>
   </#if>
   </li>
            <li class="active" id="active"><a href="${base}/postoffice">发布职位</a></li>
            <li class="me" id="me"><a href="${base}/ownjob">我的职位</a></li>
        </ul>
    </div>
    
    <div class="con_right1" id="con_right1" style="display: block">
        <div class="tttt01" style="">
        	<img src="${base}/resources/images/tttt.png"">
            <span style="">发布职位</span>
        </div>
        <ul class="cominfo">
        	<#if job_list??>
        	<#list job_list as jb>
            <li>
                <p><b>职位标题</b></p>
                <input id="zwbt"  placeholder="请输入职位标题(30字以内)" value="${jb.title }">
                <!-- <div class="onShow" id="zwbtTip"></div> -->
            </li>
            
            <li>
                <p><b>所属行业</b></p>
                <#assign id=jb.id/>
                <#assign job_tit=jb.title/>
                <#assign industry_id=jb.industry_id/>
                <#assign job_type_id=jb.job_type_id/>
                <#assign wt=jb.work_type/>
                <#assign pe=jb.city_name_1/>
                <#assign cy=jb.city_name_2/>
                <#assign ar=jb.city_name_3/>
                <#assign edu=jb.certificate_type/>
                <#assign exp=jb.work_exp_type/>
                <#assign salary=jb.salary_min+"-"+jb.salary_max>
                <#assign job_status=jb.status>
                <select id="sshy" class="sshy_1">
                    
                </select>
                <select id="industry" class="sshy_1">
                </select>
                <!-- <div class="onShow" id="industryTip"></div> -->
            </li>
            <li>
                <p><b>职位名称</b></p>
                <select id="zwmc" class="sshy_1">
                    
                </select>
                <select id="jobname"   class="sshy_1">
                    <option value="-1" selected>请选择</option>
                </select>
                <!--  <div class="onShow" id="jobnameTip"></div>-->
            </li>
            <li>
                <p><b>招聘人数</b></p>
                <input id="zprs"  type="text" placeholder="${(jb.need_count!='0')?string(jb.need_count,'请输入实际需要招聘人数') }" value="${(jb.need_count!='0')?string(jb.need_count,'') }" onkeyup="limitInput(this);" >
                <!-- <div class="onShow" id="zprsTip"></div> -->
            </li>
            <li>
                <p><b>职位类型</b></p>
                <select  id="zwlx"  >
                
                </select>
                <!-- <div class="onShow" id="zwlxTip"></div> -->
            </li>
            <li>
                <p><b>薪资范围</b></p>
                <select  id="xzfw"  >
                    <#if salary == '1000-2000'>
				    <option value="1000-2000" selected>1000-2000</option>
				    <option value="2001-4000">2001-4000</option>
				    <option value="4001-7000">4001-7000</option>
				    <option value="7001-10000">7001-10000</option>
				    <option value="10001-15000">10001-15000</option>
				    <option value="15001-20000">15001-20000</option>
				    <option value="20001-60000">20001以上</option>
				    <option value="1000-20000">面议</option>
				    <#elseif salary == '2001-4000'>
				    <option value="1000-2000">1000-2000</option>
				    <option value="2001-4000" selected>2001-4000</option>
				    <option value="4001-7000">4001-7000</option>
				    <option value="7001-10000">7001-10000</option>
				    <option value="10001-15000">10001-15000</option>
				    <option value="15001-20000">15001-20000</option>
				    <option value="20001-60000">20001以上</option>
				    <option value="1000-20000">面议</option>
				    <#elseif salary == '4001-7000'>
				    <option value="1000-2000">1000-2000</option>
				    <option value="2001-4000">2001-4000</option>
				    <option value="4001-7000" selected>4001-7000</option>
				    <option value="7001-10000">7001-10000</option>
				    <option value="10001-15000">10001-15000</option>
				    <option value="15001-20000">15001-20000</option>
				    <option value="20001-60000">20001以上</option>
				    <option value="1000-20000">面议</option>
				    <#elseif salary == '7001-10000'>
				    <option value="1000-2000">1000-2000</option>
				    <option value="2001-4000">2001-4000</option>
				    <option value="4001-7000">4001-7000</option>
				    <option value="7001-10000" selected>7001-10000</option>
				    <option value="10001-15000">10001-15000</option>
				    <option value="15001-20000">15001-20000</option>
				    <option value="20001-60000">20001以上</option>
				    <option value="1000-20000">面议</option>
				    <#elseif salary == '10001-15000'>
				    <option value="1000-2000">1000-2000</option>
				    <option value="2001-4000">2001-4000</option>
				    <option value="4001-7000">4001-7000</option>
				    <option value="7001-10000">7001-10000</option>
				    <option value="10001-15000" selected>10001-15000</option>
				    <option value="15001-20000">15001-20000</option>
				    <option value="20001-60000">20001以上</option>
				    <option value="1000-20000">面议</option>
				    <#elseif salary == '15001-20000'>
				    <option value="1000-2000">1000-2000</option>
				    <option value="2001-4000">2001-4000</option>
				    <option value="4001-7000">4001-7000</option>
				    <option value="7001-10000">7001-10000</option>
				    <option value="10001-15000">10001-15000</option>
				    <option value="15001-20000" selected>15001-20000</option>
				    <option value="20001-60000">20001以上</option>
				    <option value="1000-20000">面议</option>
				    <#elseif salary == '20001-60000'>
				    <option value="1000-2000">1000-2000</option>
				    <option value="2001-4000">2001-4000</option>
				    <option value="4001-7000">4001-7000</option>
				    <option value="7001-10000">7001-10000</option>
				    <option value="10001-15000">10001-15000</option>
				    <option value="15001-20000">15001-20000</option>
				    <option value="20001-60000" selected>20001以上</option>
				    <option value="1000-20000">面议</option>
				    <#elseif salary == '1000-20000'>
				    <option value="1000-2000">1000-2000</option>
				    <option value="2001-4000">2001-4000</option>
				    <option value="4001-7000">4001-7000</option>
				    <option value="7001-10000">7001-10000</option>
				    <option value="10001-15000">10001-15000</option>
				    <option value="15001-20000">15001-20000</option>
				   <option value="20001-60000">20001以上</option>
				    <option value="1000-20000" selected>面议</option>
				    <#else>
				    <option selected value="-1">请选择</option>
				    <option value="1000-2000">1000-2000</option>
				    <option value="2001-4000">2001-4000</option>
				    <option value="4001-7000">4001-7000</option>
				    <option value="7001-10000">7001-10000</option>
				    <option value="10001-15000">10001-15000</option>
				    <option value="15001-20000">15001-20001</option>
				    <option value="20000">20000以上</option>
				    <option value="面议">面议</option>
				    </#if>
                </select>
                <!-- <div class="onShow" id="xzfwTip"></div> -->
            </li>
            <li>
                <p><b>工作地区</b></p>
                <select id="gzdq" class="gzdq_area">
                </select>
                <select id="city" class="gzdq_area">
                </select>
                <select id="area" class="gzdq_area">
                </select>
                <!-- <div class="onShow" id="areaTip"></div> -->
            </li>
            <li>
                <p><b>具体地点</b></p>
                <input id="jtdd" placeholder="请输入具体地点" value="${(jb.address!='null')?string(jb.address,'')}">
                <!-- <div class="onShow" id="jtddTip"></div> -->
            </li>
            <li>
                <p><b>职位描述</b></p>
                <textarea id="zwms" rows="3" cols="20" placeholder="${(jb.job_description!='null')?string(jb.job_description,'')}">${(jb.job_description!="null")?string(jb.job_description,"")}</textarea>
                <!-- <div class="onShow" id="zwmsTip"></div> -->
            </li>
            <li>
                <p>学历要求</p>
                <select  id="education">
                    
                </select>
            </li>
            <li>
                <p>工作经验</p>
                <select id="work_experience">
                    
                </select>
            </li>

            <li>
                <p>所属部门</p>
                <input  type="text" placeholder="请输入30字以内" id="depart" value="${(jb.department!='null')?string(jb.department,'')}" maxlength="30" >
            </li>
            <li>
                <p>职位福利</p>
                <input  type="text" placeholder="请输入50字以内" id="benefit" value="${(jb.benefit[0]!='null')?string(jb.benefit[0],'')}" maxlength="50">
            </li>
			<li style="overflow: hidden;border: none">
                <div class="submt" >
                	<input id="Submit1" type="button" value="保存" style="background-color: #ffaa00;color: #fff;font-size: 20px;font-weight: 600;padding: 5px 40px;float: left;border: 0;width: 149px;text-align: center;" />
                </div>
                <div class="save" >
                	<input id="Submit2" type="button" value="提交审核" style="background-color: #ffaa00;color: #fff;font-size: 20px;font-weight: 600;padding: 5px 40px;float: left;border: 0;width: 149px; margin-left:50px;" />
                 </div>
			</li>
			<li class="fot" style="color: #a6a6a6;font-size: 12px;">
				<p>所有职位发布均由专人审核，请认真填写！如需要帮助请拨打客服电话：4008-907-977</p>
			</li>
			</#list>
        	</#if>
        </ul>
    </div>
    
</div>
<#include "../common/bottom.ftl">

<script src="${base}/resources/js/formValidator-4.0.1.min.js" type="text/javascript" charset="UTF-8"></script>
<script src="${base}/resources/js/formValidatorRegex.js" type="text/javascript" charset="UTF-8"></script>
<script src="${base}/resources/js/zepto.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        //数据字典部分
        getJson_industry();
        getJson_joblist();
        getJson_job_type();
        getJson_province();
        getJson_education();
        getJson_work_experience();
        
        //保存职位
        $("#Submit1").click(function(){
        	save_job(1);
        });
        
        //提交审核
        $("#Submit2").click(function(){
        	save_job(2);
        });
        
        //行业联动
        $("#sshy").change(function(){
        	getJson_nextIndustry($(this).val());
        });
        
        //职位名称
        $("#zwmc").change(function(){
        	getJson_jobName($(this).val());
        });
        
        //地区联动
        $("#gzdq").change(function(){
        	getJson_city($(this).val());
        	$("#area").empty();
    		$("#area").append("<option selected='selected' value='-1'>地区</option>");
        });
        $("#city").change(function(){
        	getJson_area($(this).val());
        });
        
        //getJson_initIndustry('${parent}');
    });
    
    
  	//所属行业
	function getJson_industry(){
		var reqURL="${base}/industry_list";
    	$.getJSON(reqURL,function(data){
    		$("#sshy").empty();
			$(data.data).each(function(){
					if(this.id==parseInt('${parent}')){
						$("#sshy").append("<option value='"+this.id+"' selected='selected'>"+this.name+"</option>");
					}else{
						$("#sshy").append("<option value='"+this.id+"'>"+this.name+"</option>");
					}
				})
				getJson_nextIndustry('${parent}');
		});
	}
  	
	//所属行业-2
	function getJson_nextIndustry(id){
		var reqURL="${base}/industry_list";
    	$.getJSON(reqURL,{
    		parentID : id
    	},function(data){
    		$("#industry").empty();
    		//$("#industry").append("<option selected='selected' vakue='-1'>请选择</option>");
			$(data.data).each(function(){
				if(this.id==parseInt('${industry_id}')){
					$("#industry").append("<option value='"+this.id+"' selected>"+this.name+"</option>");
				}else{
					$("#industry").append("<option value='"+this.id+"'>"+this.name+"</option>");
				}
			})
		});
	};
  	
	//职位名称-1
	function getJson_joblist(){
		var reqURL="${base}/job_list";
    	$.getJSON(reqURL,function(data){
    		$("#zwmc").empty();
			$(data.data).each(function(){
				if(this.name!="其他"&&this.name!="不限"){
					if(this.id==parseInt('${job_parent}')){
						$("#zwmc").append("<option value='"+this.id+"' selected='selected'>"+this.name+"</option>");
					}else{
						$("#zwmc").append("<option value='"+this.id+"'>"+this.name+"</option>");
					}
				}
			})
			getJson_jobName('${job_parent}');
		});
	}
	//职位名称-2
	function getJson_jobName(id){
		var reqURL="${base}/job_list";
    	$.getJSON(reqURL,{
    		parentID : id
    	},function(data){
    		$("#jobname").empty();
    		//$("#jobname").append("<option selected='selected' value='-1'>请选择</option>");
			$(data.data).each(function(){
				if(this.id==parseInt('${job_type_id}')){
					$("#jobname").append("<option value='"+this.id+"' selected>"+this.name+"</option>");
				}else{
					$("#jobname").append("<option value='"+this.id+"'>"+this.name+"</option>");
				}
			})
		});
	};
	
	//职位类型
	function getJson_job_type(){
	    	var reqURL="${base}/resources/json/job_type.json";
	    	$.getJSON(reqURL,function(data){
	    		$("#zwlx").empty();
				$(data).each(function(){
					if(this.value.indexOf('${wt}')>=0){
						$("#zwlx").append("<option value='"+this.label+"' selected='selected'>"+this.value+"</option>");
					}else{
						$("#zwlx").append("<option value='"+this.label+"'>"+this.value+"</option>");
					}
				})
			});
	};
	
	//地区
	function getJson_province(){
		var reqURL="${base}/city_list";
    	$.getJSON(reqURL,function(data){
    		$("#gzdq").empty();
    		var tmp=-2;
			$(data.data).each(function(){
				if(this.name.indexOf('${pe}')>=0){
					$("#gzdq").append("<option value='"+this.id+"' selected='selected'>"+this.name+"</option>");
					tmp = this.id;
				}else{
					$("#gzdq").append("<option value='"+this.id+"'>"+this.name+"</option>");
				}
				
			})
			if(tmp!=-2){
				getJson_city(tmp);
			}
		});
	}
	
	//地区-2
	function getJson_city(id){
		var reqURL="${base}/city_list";
    	$.getJSON(reqURL,{
    		'parentID':id
    	},function(data){
    		$("#city").empty();
    		$("#city").append("<option value='-1'>市/县</option>");
    		var tmp=-2;
			$(data.data).each(function(){
				if(this.name.indexOf('${cy}')>=0){
					$("#city").append("<option value='"+this.id+"' selected>"+this.name+"</option>");
					tmp = this.id;
				}else{
					$("#city").append("<option value='"+this.id+"'>"+this.name+"</option>");
				}
			})
			if(tmp!=-2){
				getJson_area(tmp);
			}
		});
	}
	//地区-3
	function getJson_area(id){
		var reqURL="${base}/city_list";
    	$.getJSON(reqURL,{
    		'parentID':id
    	},function(data){
    		$("#area").empty();
    		$("#area").append("<option value='0'>地区</option>");
			$(data.data).each(function(){
				if(this.name.indexOf('${ar}')>=0){
					$("#area").append("<option value='"+this.id+"' selected>"+this.name+"</option>");
				}else{
					$("#area").append("<option value='"+this.id+"'>"+this.name+"</option>");
				}
				
			})
		});
	}
	
	//学历
	function getJson_education(){
	    	var reqURL="${base}/resources/json/education.json";
	    	$.getJSON(reqURL,function(data){
	    		$("#education").empty();
	    		$("#education").append("<option value='-1'>请选择</option>");
				$(data).each(function(){
					if(this.value.indexOf('${edu}')>=0){
						$("#education").append("<option value='"+this.label+"' selected='selected'>"+this.value+"</option>");
					}else{
						$("#education").append("<option value='"+this.label+"'>"+this.value+"</option>");
					}
				})
			});
	};
	
	//工作经验
	function getJson_work_experience(){
	    	var reqURL="${base}/resources/json/work_experience.json";
	    	$.getJSON(reqURL,function(data){
	    		$("#work_experience").empty();
	    		$("#work_experience").append("<option value='-1'>请选择</option>");
				$(data).each(function(){
					if(this.value.indexOf('${exp}')>=0){
						$("#work_experience").append("<option value='"+this.label+"' selected='selected'>"+this.value+"</option>");
					}else{
						$("#work_experience").append("<option value='"+this.label+"'>"+this.value+"</option>");
					}
				})
			});
	};
	
	//操作职位
	function save_job(a_type){
		if(a_type==2){
			if('${enterpriseInit[0].ent_status}'=="1"){
				layer.alert("您还没有通过企业审核，只能保存职位", {icon: 0,skin: 'layer-ext-moon'});
				return;
			}
		}
		if('${job_status}'=='审核中'){
			layer.alert("审核中的职位不能编辑或提交审核", {icon: 0,skin: 'layer-ext-moon'});
			return;
		}
		var reqURL="${base}/postoffice/operatorjob";
		var salary = $("#xzfw option:selected").val();
		if($("#zwbt").val()==null || $("#zwbt").val()==""){
			layer.alert("职位标题不能为空", {icon: 2,skin: 'layer-ext-moon'});
			return
		}
		var salary_min="";
		var salary_max="";
		if(salary!="-1"){
			if(salary.indexOf("-")>0){
				salary_min = salary.substring(0,salary.indexOf("-"));
				salary_max = salary.substring(salary.indexOf("-")+1,salary.length);
			}else{
				salary_min = salary;
				salary_max = salary;
			};
		}
		if($("#jtdd").val()==null || $("#jtdd").val()==""){
			layer.alert("具体地点不能为空", {icon: 2,skin: 'layer-ext-moon'});
			return
		}
		if($("#zwms").val()==null || $("#zwms").val()==""){
			layer.alert("职位描述不能为空", {icon: 2,skin: 'layer-ext-moon'});
			return
		}
		if($("#city").val()==-1){
			layer.alert("省/市不能为空", {icon: 2,skin: 'layer-ext-moon'});
			return
		}
		//if($("#area").val()==-1){
			//layer.alert("地区不能为空", {icon: 2,skin: 'layer-ext-moon'});
			//return
		//}
		
		var education="";
		if($("#education option:selected").val()!="-1"){
			education = $("#education option:selected").val();
		}
		var expType="";
		if($("#work_experience option:selected").val()!="-1"){
			expType = $("#work_experience option:selected").val();
		};
    	$.post(reqURL,{
    		job_id : '${id}',
    		action_type : a_type,
    		title : $("#zwbt").val(),
    		industry_id : $("#industry option:selected").val(),
    		job_type_id : $("#jobname option:selected").val(),
    		need_count : $("#zprs").val(),
    		certificate_type : education,
    		work_exp_type : expType,
    		department : $("#depart").val(),
    		work_type : $("#zwlx option:selected").val(),
    		salary_min : salary_min,
    		salary_max : salary_max,
    		benefit : $("#benefit").val(),
    		city_id_1 : $("#gzdq option:selected").val(),
    		city_id_2 : $("#city option:selected").val(),
    		city_id_3 : $("#area option:selected").val(),
    		address : $("#jtdd").val(),
    		job_description : $("#zwms").val(),
    		latitude : '',
    		longitude : ''
    	},
    	function(data){
			$(data).each(function(){
				if(data.success){
					window.location="${base}/ownjob"
				}else{
					alert(data.message);
				}
			})
		});
	}
	
	//招聘人数限制
	function limitInput(o){
        var value=o.value;
        var min=1;
        var max=255;
        if(parseInt(value)<min||parseInt(value)>max){
            o.value='';
        }
    }
	
	function erroremergentMsg(){
		layer.alert("企业未设置急招职位", {icon: 7,skin: 'layer-ext-moon'});
	}
	
	function correctEmergent(){
		var reqURL="${base}/checkEme";
		$.post(reqURL,function(data){
			if(data.success){
				location.href="${base}/emergent";
			}else{
				layer.alert("企业未设置急招职位", {icon: 7,skin: 'layer-ext-moon'});
			}
		});
	}
</script>
</body>

</html>